<extend name="Layout:content" />
<block name="head">
    <link href="{:asset('css/flexslider.css')}" rel="stylesheet" type="text/css" />
    <link href="{:asset('css/news/news.css')}" rel="stylesheet" type="text/css" />
</block>
<block name="top-search">
    <form class="form-inline" action="/search" method="get">
        <select name="post_type" id="sel-search">
            <option value="news" <?php echo isset($_GET['post_type']) && $_GET['post_type']  == 'news' ? 'selected' : ''; ?>>新闻</option>
            <option value="picture" <?php echo isset($_GET['post_type']) && $_GET['post_type']  == 'picture' ? 'selected' : ''; ?>>图片</option>
            <option value="video" <?php echo isset($_GET['post_type']) && $_GET['post_type']  == 'video' ? 'selected' : ''; ?>>视频</option>
        </select>
        <input type="text" id="mykeyword" class="form-control inp-search" placeholder="请输入关键字" name="keyword" autocomplete="off">
        <input type="submit" class="btn-search btn" value="搜 索">
    </form>
</block>

<block name="content">
    <div class="container">
        <div class="row">
            <?php if (!isset($posts) || empty($posts['data'])) { ?>
            <h2>未找到任何信息！</h2>
            <?php } else { ?>
            <div class="page-introduce">
                <h2>查找{$keyword}</h2>
                <p>共找到<?php echo $posts['total']; ?>条记录！</p>
            </div>
            <div class="clearfix">
                <div class="search-list">
                    <ul class="posts">
                        <?php if (isset($posts['data'])) { foreach ($posts['data'] as $key => $value) { ?>
                        <li>
                            <h3 class="title">
                                <a href="<?php echo url('post/' . $value['post_type'] . '/' . $value['id']); ?>">
                                    <?php echo $value['title']; ?>
                                </a>
                            </h3>
                            <div class="list-unit">
                                <?php if (!empty($value['description'])) { ?>
                                <div class="deacription clearfix">
                                    <?php if (isset($value['thumb']) && !empty($value['thumb'])) { ?>
                                    <a class="alignleft" href="<?php echo url('post/' . $value['post_type'] . '/' . $value['id']); ?>">
                                        <img src="<?php echo thumb($value['thumb'], 200, 150); ?>" width="200" height="150" alt="<?php echo $value['title']; ?>">
                                    </a>
                                    <?php } ?>
                                    <div class="list-text">
                                        <p><?php echo $value['description']; ?></p>
                                    </div>
                                </div>
                                <?php } ?>
                                <div class="article-info">
                                    <span class="tags"></span>
                                    <span class="name"><?php echo $value['author']; ?></span> · <span class="time"><?php echo $value['inputtime']; ?></span>
                                </div>
                            </div>
                        </li>
                        <?php } } ?>
                    </ul>
                    <?php if(!empty($posts['page'])) { ?>
                    <div class="nav-page">
                        <ul class="pager">
                            <?php echo $posts['page']; ?>
                        </ul>
                    </div>
                    <?php } ?>
                </div>
            </div>
            <?php } ?>
        </div>
    </div>
</block>